package cn.itcast.xml.jsoup;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;
import java.net.URL;

/**
 * Jsoup 对象功能
 */
public class JsoupDemo2 {
    public static void main(String[] args) throws IOException {
        // 2.获取 Document 对象
        // 2.1获取 student.xml 文件路径
        String path = JsoupDemo2.class.getClassLoader().getResource("student.xml").getPath();
        // 2.2解析 xml 文件，加载文件进入内存，获取 Document 对象
//        Document document = Jsoup.parse(new File(path), "utf-8");
//        System.out.println(document);

        /*String str = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
                "\n" +
                " <students>\n" +
                "\n" +
                "\t<student number=\"heima_0001\">\n" +
                "\t\t<name>zhangsan</name>\n" +
                "\t\t<age>23</age>\n" +
                "\t\t<sex>male</sex>\n" +
                "\t</student>\n" +
                "\n" +
                "\t<student number=\"heima_0002\">\n" +
                "\t\t<name>lisi</name>\n" +
                "\t\t<age>24</age>\n" +
                "\t\t<sex>female</sex>\n" +
                "\t</student>\n" +
                "\t\t \n" +
                " </students>";
        Document document = Jsoup.parse(str);
        System.out.println(document);*/

        URL url = new URL("https://www.baidu.com"); // 代表网络中一个资源的路径
        Document document = Jsoup.parse(url, 3000);
        System.out.println(document);


    }
}
